package cn.wowjoy.pda.android_pharmacy.ui.activity.hospital;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import cn.wowjoy.pda.android_pharmacy.R;
import cn.wowjoy.pda.android_pharmacy.common.core.BaseActivity;
import cn.wowjoy.pda.android_pharmacy.common.utils.Contants;
import cn.wowjoy.pda.android_pharmacy.common.widget.MyToast;
import cn.wowjoy.pda.android_pharmacy.databinding.ActivityHandInputBinding;
import cn.wowjoy.pda.android_pharmacy.mvvm.presenter.HandInputPresenter;
import cn.wowjoy.pda.android_pharmacy.mvvm.vm.HandInputViewModel;

public class HandInputActivity extends BaseActivity<ActivityHandInputBinding,HandInputViewModel,HandInputPresenter> {


    @Override
    protected void init(Bundle savedInstanceState) {
        binding.setPresenter(presenter);
        binding.setViewModel(viewModel);

        binding.hospitalIndexTitle.titleTextTv.setText("手动输入单号");
        binding.hospitalIndexTitle.titleBackTv.setText("");
        binding.hospitalIndexTitle.titleBackLl.setVisibility(View.VISIBLE);
        binding.hospitalIndexTitle.titleBackLl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                setResult(Contants.RESULT_HAND_FAIL_CODE);
                finish();
            }
        });
        binding.btMedicineDetailStart.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(binding.tvHandPillNumber.getText().toString().trim().equals("") || binding.tvHandPillNumber.getText().toString().trim().length() == 0){
                    new MyToast(HandInputActivity.this).showinfo("请输入药单号");
                    return;
                }
                Intent intent=new Intent();
                intent.putExtra("handInput", binding.tvHandPillNumber.getText().toString().trim());
                setResult(Contants.RESULT_HAND_SUCCESS_CODE,intent);
                finish();
            }
        });
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_hand_input;
    }

    @Override
    protected Class<HandInputPresenter> getPresenterClass() {
        return HandInputPresenter.class;
    }

    @Override
    protected Class<HandInputViewModel> getViewModelClass() {
        return HandInputViewModel.class;
    }
}
